import { Component } from '@angular/core';
import { IonicPage, ModalController, NavParams } from 'ionic-angular';
// 常量
import * as PageConstant from '../../../../constant/pageConstant';
/**
 * 手机运营商认证
 */
@IonicPage()
@Component({
  selector: 'page-mine-telephone',
  templateUrl: 'mine-telephone.html'
})
export class MineTelephonePage{

  // 是否认证运营商
  private mobileState: any;
  // 运行商认证状态
  private mobileText: string;
  // 按钮状态
  private buttonText: string;
  constructor(
    public modalCtrl: ModalController,
    public navParams: NavParams,
  )
  {
    this.mobileState = this.navParams.get('mobileState');
    this.changeHtmlStatus();
  }
  // 修改页面状态
  private changeHtmlStatus(): void
  {
    if(!this.mobileState){ // 未完成
      this.mobileText= '运营商认证未完成';
      this.buttonText= `未 认 证`;
      return;
    }
    if(this.mobileState===1){ // 1 为进行中
      this.mobileText= '运营商认证进行中';
      this.buttonText= '认 证 进 行 中';
      return;
    }
    if(this.mobileState===2){ //2 为完成
      this.mobileText= '运营商认证已完成';
      this.buttonText= '已 认 证';
      return;
    }
  }
  // 执行认证
  executeAuth(){
    let modal = this.modalCtrl.create(PageConstant.TelephoneAuthPage, {},{
      showBackdrop: false,
      enableBackdropDismiss: false,
    });
    modal.onDidDismiss(mobileState=>{
      this.mobileState= mobileState;
      this.changeHtmlStatus();
    });
    modal.present();
  }

}

